﻿using CosyTrade.Store;
using CosyTrade.UI;

namespace CosyTrade.ClientForm
{
    public partial class CompanyProductInfo : UserControlBase
    {
        private CompanyProductView currentCompanyProductView;

        public CompanyProductInfo()
        {
            InitializeComponent();
        }
        
        public CompanyProductView CurrentCompanyProductView
        {
            get { return currentCompanyProductView; }
            set
            {
                currentCompanyProductView = value;
                if (value != null) DataSourceChanged();
            }
        }

        private void DataSourceChanged()
        {
            txtProductName.EditValue = currentCompanyProductView.Store.Products.Caption;
            txtBookCount.EditValue = currentCompanyProductView.Store.BookCount;
            txtStore.EditValue = currentCompanyProductView.Store.StoreCount;
        }
    }
}
